<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户详细信息</title>
    <link rel="stylesheet" href="../../../backstage/css/x-admin.css" media="all">
    <script src="../../../backstage/lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../../backstage/js/x-layui.js" charset="utf-8"></script>
</head>
    
<body>
<div class="x-body">

    <div class="pd-20">
      <table  class="layui-table" lay-skin="line">
        <tbody>
          <tr>.
            确定要重置密码？
          </tr>
        </tbody>
      </table>
        <div class="layui-input-inline" id="search"style="width:80px">
            <input type="button"  id="reset" class="layui-btn"   value="确定重置密码">
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'layer'], function() {
        $ = layui.jquery;
        var form = layui.form(),
                layer = layui.layer;
        $(document).ready(function () {
            //获取传递过来的localStorage
            var id = window.localStorage.getItem('msg');
            console.log(id);
            $.ajax({
                type: 'POST',
                url: '/userManager/selectById',
                dataType: "json",
                data: {uid: id},
                error: function () {
                    console.log("失败");
                },
                success: function (result) {

                    $("#reset").click(function () {

                        $.ajax({
                            type: 'POST',
                            url: '/user/changePwd',
                            dataType: "json",
                            data: {
                                username: result.username,
                                oldPwd: result.pwd,
                                newPwd: "123456"
                            },
                            error: function () {
                                alert("失败");
                            },
                            success: function (data) {
                                console.log(data);
                                if (data.msg) {
                                    alert("重置成功");
                                }
                            }
                        });
                    })
                }
            })
        });
    });
</script>
</body>
</html>